#!/bin/sh
# This shell script used to cross compile file command for fl2440
# Before excute this shell script, please download the source code to here first.

APP_NAME=tree-1.5.2
PATCH_FILE=./patch/fl2440-$APP_NAME.patch
PACK_SUFFIX=tar.gz

mv tree*1.5.2*tar.gz ${APP_NAME}.${PACK_SUFFIX}

if [ ! -d ${APP_NAME} ] ; then
   if [ -f ${APP_NAME}.${PACK_SUFFIX} -a -f $PATCH_FILE ] ; then
        echo "==================================================="
        echo "+           Decompress $APP_NAME now...            "
        echo "==================================================="
        rm -rf ${APP_NAME}
        tar -xzf ${APP_NAME}.${PACK_SUFFIX}
        
        echo "===================================================" 
        echo "+                 Patching now...                  " 
        echo "===================================================" 
        patch -p0 < $PATCH_FILE 
  else 
     echo "================================================================" 
     echo "+       ERROR: Missing $APP_NAME Source Code Packet!              " 
     echo "+ Plese download ${APP_NAME}.${PACK_SUFFIX} to here and try again! " 
     echo "+ Download: http://ftp.de.debian.org/debian/pool/main/t/tree/tree_1.5.2.orig.tar.gz " 
     echo "================================================================" 
     exit; 
  fi 
fi

cd $APP_NAME && make

